package com.ruoyi.web.controller.Resource;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ChainInformation;
import com.ruoyi.system.service.IChainInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 产业链链点信息Controller
 * 
 * @author ruoyi
 * @date 2023-09-10
 */
@RestController
@RequestMapping("/Resource/information")
public class ChainInformationController extends BaseController
{
    @Autowired
    private IChainInformationService chainInformationService;

    /**
     * 查询产业链链点信息列表
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:list')")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(ChainInformation chainInformation)
    {
        startPage();
        List<ChainInformation> list = chainInformationService.selectChainInformationList(chainInformation);
        return getDataTable(list);
    }

    /**
     * 导出产业链链点信息列表
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:export')")
    @Anonymous
    @Log(title = "产业链链点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChainInformation chainInformation)
    {
        List<ChainInformation> list = chainInformationService.selectChainInformationList(chainInformation);
        ExcelUtil<ChainInformation> util = new ExcelUtil<ChainInformation>(ChainInformation.class);
        util.exportExcel(response, list, "产业链链点信息数据");
    }

    /**
     * 获取产业链链点信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:query')")
    @Anonymous
    @GetMapping(value = "/{cId}")
    public AjaxResult getInfo(@PathVariable("cId") Long cId)
    {
        return success(chainInformationService.selectChainInformationByCId(cId));
    }

    /**
     * 新增产业链链点信息
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:add')")
    @Anonymous
    @Log(title = "产业链链点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChainInformation chainInformation)
    {
        return toAjax(chainInformationService.insertChainInformation(chainInformation));
    }

    /**
     * 修改产业链链点信息
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:edit')")
    @Anonymous
    @Log(title = "产业链链点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChainInformation chainInformation)
    {
        return toAjax(chainInformationService.updateChainInformation(chainInformation));
    }

    /**
     * 删除产业链链点信息
     */
//    @PreAuthorize("@ss.hasPermi('Resource:information:remove')")
    @Anonymous
    @Log(title = "产业链链点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cIds}")
    public AjaxResult remove(@PathVariable Long[] cIds)
    {
        return toAjax(chainInformationService.deleteChainInformationByCIds(cIds));
    }
}
